<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="/static/Admin/css/bootstrap-select.min.css">
    <script src="/static/Admin/js/bootstrap-select.min.js"></script>
</head>
<body>
        <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel" type="{$request}">{$title}</h4>
            </div>
            <div class="modal-body">
                    <div class="row clearfix">
                            <div class="col-md-12 column">
                                <div class="alert alert-dismissable alert-info">
                                <button type="button" class="close">×</button>
                                <p></p>
                                </div>
                            </div>
                        </div>
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">{:lang('Chinese')}</a></li>
                <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">{:lang('English')}</a></li>
                <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">{:lang('Portuguese')}</a></li>
            </ul>
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="home">
                    <form class="form-horizontal" style="margin-top: 20px;">
                        <div class="form-group">
                          <label for="inputEmail3" class="col-sm-2 control-label">{:lang('owned_function')}：</label>
                          <div class="col-sm-2">
                            <select class="selectpicker" name="pid"  data-live-search="true">
                                    {if isset($info)}
                                    {if condition="$info.pid==0"}
                                        <option value="0">--{:lang('please_select')}--</option>
                                    {/if}
                                    {/if}
                                {volist name="allParent" id="vo"}
                                    {if isset($vo.child)}
                                        <option value="{$vo.id}" {if ($vo.id == $pid)}selected{/if}>{$vo.level|default=0|str_repeat='&emsp;',###*2}<i style="width: 20px;height: 20px;display: inline-block"></i>{$vo.name_zh}</option>
                                    {else /}
                                        <!-- <option value="0">--请选择--</option> -->
                                        <option value="{$vo.id}" >{$vo.name_zh}</option>
                                    {/if}
                                    {$vo.name_zh}
                                </a>
                                {/volist}
                            </select>
                          </div>
                        </div>
                        {if isset($info)}
                        <input type="hidden" name="id" value="{$info.id|default=''}" class="form-control" >
                        {/if}
                        <div class="form-group">
                          <label  class="col-sm-2 control-label">{:lang('function_name')}：</label>
                          <div class="col-sm-2">
                            <input type="text" name="name" value="{$info.name_zh|default=''}" class="form-control" >
                          </div>
                        </div>
                        <div class="form-group">
                          <label  class="col-sm-2 control-label">{:lang('controller')}：</label>
                          <div class="col-sm-2">
                            <input type="text" name="control" value="{$info.control|default=''}" class="form-control linkage" >
                          </div>
                        </div>
                        <div class="form-group">
                          <label  class="col-sm-2 control-label">{:lang('method')}：</label>
                          <div class="col-sm-2">
                            <input type="text" name="option" value="{$info.option|default=''}" class="form-control linkage">
                          </div>
                        </div>
                        <div class="form-group">
                          <label for="inputPassword3" class="col-sm-2 control-label">{:lang("select_model")}：</label>
                          <div class="col-sm-2">
                            <input type="text" name="style" value="{$info.style|default=''}" class="form-control linkage" >
                          </div>
                        </div>
                        <div class="form-group">
                          <label  class="col-sm-2 control-label">{:lang('menu_yes_or_no')}：</label>
                          <div class="col-sm-2">
                              {if isset($info)}
                                  {if condition="($info.is_menu == 1)"}
                                      <label class="radio-inline">
                                          <input type="radio" class="chelinkage" name="is_menu"  value="1" checked>{:lang('yes')}
                                      </label>
                                      <label class="radio-inline">
                                          <input type="radio" class="chelinkage" name="is_menu" value="0">{:lang('no')}
                                      </label>
                                  {else /}
                                      <label class="radio-inline">
                                          <input type="radio" class="chelinkage" name="is_menu" value="1" >{:lang('yes')}
                                      </label>
                                      <label class="radio-inline">
                                          <input type="radio" class="chelinkage" name="is_menu" value="0" checked>{:lang('no')}
                                      </label>
                                  {/if}
                              {else /}
                                  <label class="radio-inline">
                                      <input type="radio" class="chelinkage" name="is_menu"  value="1" checked>{:lang('yes')}
                                  </label>
                                  <label class="radio-inline">
                                      <input type="radio" class="chelinkage" name="is_menu" value="0">{:lang('no')}
                                  </label>
                              {/if}
                          </div>
                        </div>
                        <div class="form-group">
                          <label for="inputPassword3" class="col-sm-2 control-label">{:lang("whether_to_disable")}：</label>
                          <div class="col-sm-2">
                              {if isset($info)}
                                  {if condition="($info.disable == 1)"}
                                      <label class="radio-inline">
                                          <input type="radio" class="chelinkage" name="disable" value="1" checked>{:lang('yes')}
                                      </label>
                                      <label class="radio-inline">
                                          <input type="radio" class="chelinkage" name="disable" value="0" >{:lang('no')}
                                      </label>
                                  {else /}
                                      <label class="radio-inline">
                                          <input type="radio" class="chelinkage" name="disable" value="1" >{:lang('yes')}
                                      </label>
                                      <label class="radio-inline">
                                          <input type="radio" class="chelinkage" name="disable" value="0" checked>{:lang('no')}
                                      </label>
                                  {/if}
                              {else /}
                                  <label class="radio-inline">
                                      <input type="radio" class="chelinkage" name="disable" value="1">{:lang('yes')}
                                  </label>
                                  <label class="radio-inline">
                                      <input type="radio" class="chelinkage" name="disable"  value="0" checked>{:lang('no')}
                                  </label>
                              {/if}
                          </div>
                        </div>
                        <div class="form-group">
                          <label for="inputPassword3" class="col-sm-2 control-label">{:lang('classify')}：</label>
                          <div class="col-sm-2">
                            <input type="text" name="drank" value="{$info.drank|default='10'}" class="form-control linkage" >
                          </div>
                        </div>
                                    <input type="hidden" name="olddrank" value="{$info.drank|default=''}" class="form-control linkage" >
                    </form>
                </div>

                <div role="tabpanel" class="tab-pane" id="profile">
                        <form class="form-horizontal" style="margin-top: 20px;">
                                <div class="form-group">
                                  <label for="inputEmail3" class="col-sm-2 control-label">en_{:lang("owned_function")}：</label>
                                  <div class="col-sm-2">
                                    <select class="selectpicker" name="pid"  data-live-search="true">
                                    {if isset($info)}
                                    {if condition="$info.pid==0"}
                                        <option value="0">--{:lang('please_select')}--</option>
                                    {/if}
                                    {/if}
                                        {volist name="allParent" id="vo"}
                                            {if isset($vo.child)}
                                                <option value="{$vo.id}" {if ($vo.id == $pid)}selected{/if}>{$vo.level|default=0|str_repeat='&emsp;',###*2}<i style="width: 20px;height: 20px;display: inline-block"></i>{$vo.name_en}</option>
                                            {else /}
                                                <!-- <option value="0">--请选择--</option> -->
                                                <option value="{$vo.id}" >{$vo.name_en}</option>
                                            {/if}
                                            {$vo.name_en}
                                        </a>
                                        {/volist}
                                    </select>
                                  </div>
                                </div>
                                {if isset($info)}
                                <input type="hidden" name="id" value="{$info.id|default=''}" class="form-control" >
                                {/if}
                                <div class="form-group">
                                  <label  class="col-sm-2 control-label">{:lang('function_name')}：</label>
                                  <div class="col-sm-2">
                                    <input type="text" name="name" value="{$info.name_en|default=''}" class="form-control" >
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label  class="col-sm-2 control-label">{:lang('controller')}：</label>
                                  <div class="col-sm-2">
                                    <input type="text" name="control" value="{$info.control|default=''}" class="form-control linkage" >
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label  class="col-sm-2 control-label">{:lang('method')}：</label>
                                  <div class="col-sm-2">
                                    <input type="text" name="option" value="{$info.option|default=''}" class="form-control linkage">
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label for="inputPassword3" class="col-sm-2 control-label">{:lang("select_model")}：</label>
                                  <div class="col-sm-2">
                                    <input type="text" name="style" value="{$info.style|default=''}" class="form-control linkage" >
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label  class="col-sm-2 control-label">{:lang("menu_yes_or_no")}：</label>
                                  <div class="col-sm-2">
                                      {if isset($info)}
                                          {if condition="($info.is_menu == 1)"}
                                              <label class="radio-inline">
                                                  <input type="radio" class="chelinkage" name="is_menu"  value="1" checked>{:lang('yes')}
                                              </label>
                                              <label class="radio-inline">
                                                  <input type="radio" class="chelinkage" name="is_menu" value="0">{:lang('no')}
                                              </label>
                                          {else /}
                                              <label class="radio-inline">
                                                  <input type="radio" class="chelinkage" name="is_menu" value="1" >{:lang('yes')}
                                              </label>
                                              <label class="radio-inline">
                                                  <input type="radio" class="chelinkage" name="is_menu" value="0" checked>{:lang('no')}
                                              </label>
                                          {/if}
                                      {else /}
                                          <label class="radio-inline">
                                              <input type="radio" class="chelinkage" name="is_menu"  value="1" checked>{:lang('yes')}
                                          </label>
                                          <label class="radio-inline">
                                              <input type="radio" class="chelinkage" name="is_menu" value="0">{:lang('no')}
                                          </label>
                                      {/if}
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label for="inputPassword3" class="col-sm-2 control-label">{:lang("whether_to_disable")}：</label>
                                  <div class="col-sm-2">
                                      {if isset($info)}
                                          {if condition="($info.disable == 1)"}
                                              <label class="radio-inline">
                                                  <input type="radio" class="chelinkage" name="disable" value="1" checked>{:lang('yes')}
                                              </label>
                                              <label class="radio-inline">
                                                  <input type="radio" class="chelinkage" name="disable" value="0" >{:lang('no')}
                                              </label>
                                          {else /}
                                              <label class="radio-inline">
                                                  <input type="radio" class="chelinkage" name="disable" value="1" >{:lang('yes')}
                                              </label>
                                              <label class="radio-inline">
                                                  <input type="radio" class="chelinkage" name="disable" value="0" checked>{:lang('no')}
                                              </label>
                                          {/if}
                                      {else /}
                                          <label class="radio-inline">
                                              <input type="radio" class="chelinkage" name="disable" value="1">{:lang('yes')}
                                          </label>
                                          <label class="radio-inline">
                                              <input type="radio" class="chelinkage" name="disable"  value="0" checked>{:lang('no')}
                                          </label>
                                      {/if}
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label for="inputPassword3" class="col-sm-2 control-label">{:lang('classify')}：</label>
                                  <div class="col-sm-2">
                                    <input type="text" name="drank" value="{$info.drank|default=''}" class="form-control linkage" >
                                  </div>
                                </div>
                                    <input type="hidden" name="olddrank" value="{$info.drank|default='10'}" class="form-control linkage" >
                            </form>
                </div>

                <div role="tabpanel" class="tab-pane" id="messages">
                        <form class="form-horizontal"  style="margin-top: 20px;">
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">zh_{:lang("owned_function")}：</label>
                                <div class="col-sm-2">
                                <select class="selectpicker" name="pid"  data-live-search="true">
                                {if isset($info)}
                                {if condition="$info.pid==0"}
                                    <option value="0">--{:lang('please_select')}--</option>
                                {/if}
                                {/if}
                                    {volist name="allParent" id="vo"}
                                        {if isset($vo.child)}
                                            <option value="{$vo.id}" {if ($vo.id == $pid)}selected{/if}>{$vo.level|default=0|str_repeat='&emsp;',###*2}<i style="width: 20px;height: 20px;display: inline-block"></i>{$vo.name_pt}</option>
                                        {else /}
                                            <!-- <option value="0">--请选择--</option> -->
                                            <option value="{$vo.id}" >{$vo.name_pt}</option>
                                        {/if}
                                        {$vo.name_pt}
                                    </a>
                                    {/volist}
                                </select>
                                </div>
                            </div>
                            {if isset($info)}
                            <input type="hidden" name="id" value="{$info.id|default=''}" class="form-control" >
                            {/if}
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">{:lang('function_name')}：</label>
                                <div class="col-sm-2">
                                <input type="text" name="name" value="{$info.name_pt|default=''}" class="form-control" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">{:lang('controller')}：</label>
                                <div class="col-sm-2">
                                <input type="text" name="control" value="{$info.control|default=''}" class="form-control linkage" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">{:lang('method')}：</label>
                                <div class="col-sm-2">
                                <input type="text" name="option" value="{$info.option|default=''}" class="form-control linkage">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label">{:lang("select_model")}：</label>
                                <div class="col-sm-2">
                                <input type="text" name="style" value="{$info.style|default=''}" class="form-control linkage" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">{:lang("menu_yes_or_no")}：</label>
                                <div class="col-sm-2">
                                    {if isset($info)}
                                        {if condition="($info.is_menu == 1)"}
                                            <label class="radio-inline">
                                                <input type="radio" class="chelinkage" name="is_menu"  value="1" checked>{:lang('yes')}
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" class="chelinkage" name="is_menu" value="0">{:lang('no')}
                                            </label>
                                        {else /}
                                            <label class="radio-inline">
                                                <input type="radio" class="chelinkage" name="is_menu" value="1" >{:lang('yes')}
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" class="chelinkage" name="is_menu" value="0" checked>{:lang('no')}
                                            </label>
                                        {/if}
                                    {else /}
                                        <label class="radio-inline">
                                            <input type="radio" class="chelinkage" name="is_menu"  value="1" checked>{:lang('yes')}
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" class="chelinkage" name="is_menu" value="0">{:lang('no')}
                                        </label>
                                    {/if}
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label">{:lang("whether_to_disable")}：</label>
                                <div class="col-sm-2">
                                    {if isset($info)}
                                        {if condition="($info.disable == 1)"}
                                            <label class="radio-inline">
                                                <input type="radio" class="chelinkage" name="disable" value="1" checked>{:lang('yes')}
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" class="chelinkage" name="disable" value="0" >{:lang('no')}
                                            </label>
                                        {else /}
                                            <label class="radio-inline">
                                                <input type="radio" class="chelinkage" name="disable" value="1" >{:lang('yes')}
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" class="chelinkage" name="disable" value="0" checked>{:lang('no')}
                                            </label>
                                        {/if}
                                    {else /}
                                        <label class="radio-inline">
                                            <input type="radio" class="chelinkage" name="disable" value="1">{:lang('yes')}
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" class="chelinkage" name="disable"  value="0" checked>{:lang('no')}
                                        </label>
                                    {/if}
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label">{:lang('classify')}：</label>
                                <div class="col-sm-2">
                                <input type="text" name="drank" value="{$info.drank|default='10'}" class="form-control linkage" >
                                </div>
                            </div>

                                <input type="hidden" name="olddrank" value="{$info.drank|default=''}" class="form-control linkage" >
                            </div>
                        </form>
                </div>
            </div>
           
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">{:lang('close')}</button>
                <button type="button" class="btn btn-primary subfn">{:lang('confirm')}</button>
            </div>
            <script>
                $('.selectpicker').selectpicker()
                $.fn.serializeObject = function() {
                    var o = {};
                    var a = this.serializeArray();
                    $.each(a, function() {
                        if (o[this.name] !== undefined) {
                            if (!o[this.name].push) {
                                o[this.name] = [o[this.name]];
                            }
                            o[this.name].push(this.value || '');
                        } else {
                            o[this.name] = this.value || '';
                        }
                    });
                    return o;
                    };
            $('.linkage').change(function(){
                val=$(this).val()
                $("input[name='"+$(this).attr('name')+"']").each(function(){
                    $(this).val(val)
                })
            })
            $('.chelinkage').change(function(){
                val=$(this).val()
                $("input[name='"+$(this).attr('name')+"']").each(function(){
                    if($(this).val()==val){
                        $(this).prop('checked',true)
                    }
                    
                })
            })
            $('.subfn').click(function(){
                if($('#myModalLabel').attr('type') == "add"){
                  var url = "/admin/menu/addopen?request=insert";
                }else if($('#myModalLabel').attr('type') == "edit"){
                  var url = '/admin/menu/editopen?request=update';
                }
                var data={
                    zh:$('.form-horizontal').eq(0).serializeObject(),
                    en:$('.form-horizontal').eq(1).serializeObject(),
                    pt:$('.form-horizontal').eq(2).serializeObject(),
                }
                console.log(data)
                 $.ajax({
                    type: "POST",
                    url: url,
                    data,
                    dataType: "json",
                    success: function(data){
                      data = JSON.parse(data)
                      if(data.status==1){
                        change_mes_type('.alert',data.status)
                        $('.alert').show()
                        $('.alert p').html('*'+data.msg+'<br>')
                          $('#prosModal').modal('hide')
                      }else{
                        change_mes_type('.modal-body .alert',data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*'+data.msg+'<br>')
                         // toastr.warning(data.msg);
                      }
                    }
               }); 
            });
            $('.selectpicker').change(function(){
                $('.selectpicker').val($(this).val())
                $('.selectpicker').selectpicker('refresh');
            })
            </script>
</body>
</html>